package cn.itcast.hotel.config;


import cn.itcast.hotel.constants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {

    @Bean
    TopicExchange topicExchange(){
        return  new TopicExchange(MqConstants.HOTEL_EXCHANGE);
    }

    @Bean
    Queue queueInsert(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    Queue queueDelete(){
        return new Queue(MqConstants.HOTEL_DELETE_QUEUE);
    }

    @Bean
    Binding insertBinding(){
        return BindingBuilder.bind(queueInsert()).to(topicExchange()).with(MqConstants.HOTEL_INSERT_KEY);

    }

    @Bean
    Binding deleteBinding(){
        return BindingBuilder.bind(queueDelete()).to(topicExchange()).with(MqConstants.HOTEL_DELETE_KEY);

    }
}
